//
//  LDSPersonalTableCell.m
//  TestCategory
//
//  Created by kai_leedarson on 2017/10/19.
//Copyright © 2017年 maple_leedarson. All rights reserved.
//

#import "LDSPersonalTableCell.h"
#import "LDSPersonalModel.h"
#import "UIResponder+Router.h"

@implementation LDSPersonalTableCell

- (void)viewSetup {
    self.textField.placeholder  = @"Please Fill";
    [self.chooseButton setTitle:@"Please Choose" forState:UIControlStateNormal];
    [self.chooseButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [self.chooseButton addTarget:self action:@selector(chooseButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)frameSetup {
    
}

- (void)setModel:(LDSPersonalModel *)model
{
    [super setModel:model];
    if (model) {
        //将model 的数值 传递给 cell
        self.textLabel.text = model.text;
        if ([model.text isEqualToString:@"Name"]) {
            self.textField.hidden = NO;
            self.chooseButton.hidden = YES;
        } else {
            self.textField.hidden = YES;
            self.chooseButton.hidden = NO;
        }
        if (model.detailInfo) {
            [self.chooseButton setTitle:model.detailInfo forState:UIControlStateNormal];
        }
    }
}

+ (CGFloat)height {
    return 55.0f;
}

- (void)chooseButtonClicked:(UIButton *)sender {
    LDSPersonalModel *obj  =(LDSPersonalModel *)_model;
    NSDictionary *dic = @{@"cell":self};
    [self routerEventWithName:obj.text userInfo:dic];
}

@end
